Inside Macintosh: Macintosh Toolbox Essentials

Previous | Chapter Top | Chapter Contents | Next

The Window Color Table Record

The user controls the colors used for the window frame and text highlighting through the Color control panel. Ordinarily, your application doesn't override the user's color choices, which are stored in a default window color table. If you have some extraordinary need to control window colors, you can do so by defining window color tables for your application's windows.

The Window Manager maintains window color information tables in a data structure of type WinCTab .

You can define your own window color table and apply it to an existing window through the SetWinColor function (SetWinColor) .

To establish the window color table for a window when you create it, you provide a window color table ( 'wctb' ) resource with the same resource ID as the 'WIND' resource that defines the window.

The WCTabPtr data type is a pointer to a window color table record, and the WTabHandle is a handle to a window color table record. The WinCTab data type defines a window color table record.

struct WinCTab {
    long            wCSeed;         /* reserved */
    short           wCReserved;     /* reserved */
    short           ctSize;         /* number of entries in table --1*/
    ColorSpec       ctTable[5];     /* array of color specification */
                                    /* records */
};
typedef struct WinCTab WinCTab;
typedef WinCTab *WCTabPtr, **WCTabHandle;
wCSeed
Reserved.
wCReserved
Reserved.
ctSize
The number of entries in the table, minus 1. If you're building a color table for use with the standard window definition function, the maximum value of this field is 12. Custom window definition functions can use color tables of any size.
ctTable
An array of colorSpec records.
In a window color table, each colorSpec record specifies a window part in the first word and an RGB value in the other three words:
                    struct ColorSpec {
                        short       value;      /* part identifier */
                        RGBColor rgb;           /* RGB value */
                    };
The value field of a colorSpec record specifies a constant that defines which part of the window the color controls. For the window color table used by the standard window definition function, you can specify one of the values listed in "Part Identifiers for ColorSpec Records" .

Note

The part codes in System 5 and System 6 are significantly different from the part codes described here, which apply only to System 7 .

The window parts can appear in any order in the table.
The rgb field of a ColorSpec record contains three words of data that specify the red, green, and blue values of the color to be used. The RGBColor data type is defined in Inside Macintosh: Imaging.

When your application creates a window, the Window Manager first looks for a resource of type 'wctb' with the same resource ID as the 'WIND' resource used for the window. If it finds one, it creates a window color table for the window from the information in that resource, and then displays the window in those colors. If it doesn't find a window color table resource with the same resource ID as your window resource, the Window Manager uses the default system window color table, read into the heap during application startup.

After creating a window, you can change the entries in a window's window color table with the SetWinColor function SetWinColor .

See "The Window Color Table Resource" for a description of the window color table resource.


© 1997 Apple Computer, Inc.

Previous | Chapter Top | Chapter Contents | Next